package org.noote.libs.robot.stepper;

import java.util.ArrayList;

public class StepperRobot_AnimationStep {

	public float _fDuration = 0; // Second !
	public ArrayList<Unit> _units = new ArrayList<Unit>();
	
	class Unit
	{
		int _iServo;
		float _fPosition;
		
		public Unit(int iServo, float fPosition)
		{
			_iServo = iServo;
			_fPosition = fPosition;
		}
	}
	
	public void setDuration(float fDuration)
	{
		_fDuration = fDuration;
	}
	
	public Unit setPosition(int iServo, float fPosition)
	{
		// already registred ?
		Unit unit = find(iServo);
		if(unit == null)
		{
			// add new one
			Unit new_unit = new Unit(iServo, fPosition);
			_units.add(new_unit);
			return new_unit;
		}
		
		// else modify it
		unit._fPosition = fPosition;
		return unit;
	}
	
	public Unit find(int iServo)
	{
		for(Unit u : _units)
		{
			if(u._iServo == iServo)
				return u;
		}
		return null;
	}
}
